$(function () {
    var send = ctx + "system/sendBack";
    let wfId = $('#pkId').val();
    //拟派电话工单列表
    var options = {
        url: send + '/simulacrumList/' + wfId,
        sortName: "pkid",
        modalName: "派单",
        sortOrder: "desc",
        uniqueId: "pkId",
        removeUrl: send + "/remove",
        showColumns: false,                  //是否显示所有的列（选择显示的列）
        showRefresh: false,
        showSearch: false,
        showToggle: false,
        fixedColumns: true,
        fixedNumber: 1,
        fixedRightNumber: 2,
        columns: [{
            field: 'pkId',
            title: 'id',
            visible: false
        },
            {
                field: 'seqName',
                title: '交办次序',
                width: 100,
                align: 'center',
            }, {
                field: 'sortName',
                title: '办理性质',
                width: 100,
                align: 'center',
            }, {
                field: 'dealName',
                title: '办理方式',
                width: 100,
                align: 'center',
            }, {
                field: 'sbdeptName',
                title: '承办单位',
                width: 240,
                align: 'center',
            }, {
                field: 'sdeptName',
                title: '派发单位',
                width: 240,
                align: 'center',
            }, {
                field: 'backLimit',
                title: '要求期限',
                width: 160,
                align: 'center',
            }, {
                field:'sendTime',
                title:'派发时间',
                align:'center',
                width: 160
            }, {
                field: 'sendState',
                title: '办理情况',
                align: 'center',
                sortable: true,
                formatter: function (value, row, index) {
                    return fmtSBSendState(value, row, index);
                }
            },{
                field : 'wfId',
                title: '操作',
                width: 60,
                align: 'center',
                valign: 'middle',
                formatter: actionFormatter
            }]
    };
    $.table.init(options);
});

function actionFormatter(value, row, index) {
    var id = value;
    var result = "";
    result += "<a href='javascript:;' class='btn btn-xs blue' onclick=\"EditViewById('" + id + "','"+row.pkId+"')\" title='编辑'><span>编辑</span></a>";
    result += "<a href='javascript:;' class='btn btn-xs red' onclick=\"$.operate.remove('"+row.pkId+"')\" title='删除'><span>删除</span></a>";
    return result;
}

function EditViewById(wfId,sbId){
    var url = send + "/editDept/"+wfId+"/"+sbId;
    var width = '70%';
    var config = {
        id: 'deptdialog',
        title: '拟办部门',
        width: width,
        url: url,
        callBack: function(index, layero) {
            var iframeWin = layero.find('iframe')[0];
            iframeWin.contentWindow.submitHandler();
        }
    };
    $.modal.openOptions(config);
    // $.modal.open('修改拟办部门', url);
}